package com.gc.cscott.domain;

import java.util.List;
import java.util.regex.Pattern;

/**
 *
 * @author root
 */
public class Platform {
    String name;
    String executable;
    List<String> run;
    transient Pattern patternExecutable = null;
    String source;
    transient Pattern sourceCompiled = null;
    List<String> compile;
    boolean copyBeforeRun = false;

    public List<String> getRun() {
        return run;
    }

    public String getName() {
        return name;
    }

    public String getExecutable() {
        return executable;
    }

    public List<String> getCompile() {
        return compile;
    }

    public String getSource() {
        return source;
    }

    public boolean isCopyBeforeRun() {
        return copyBeforeRun;
    }

    public void setCopyBeforeRun(boolean copyBeforeRun) {
        this.copyBeforeRun = copyBeforeRun;
    }

    public boolean matchesExecutable(String fileName){
        if (patternExecutable==null){
            patternExecutable = Pattern.compile(executable, Pattern.CASE_INSENSITIVE);
        }
        return patternExecutable.matcher(fileName).matches();
    }

    public boolean matchesSource(String fileName){
        if (sourceCompiled==null){
            sourceCompiled = Pattern.compile(source, Pattern.CASE_INSENSITIVE);
        }
        return sourceCompiled.matcher(fileName).matches();
    }
}
